package main.java.trans;

import main.java.Employee;
import main.java.PaymentClassification;
import main.java.PayrollDatabase;
import main.java.Transaction;
import main.java.classification.HourlyClassification;
import main.java.classification.TimeCard;
import main.java.exception.NotHourlyClassificationException;

public class TimeCardTransaction implements Transaction {

    private int empId;
    private String date;
    private double hours;
    private Employee employee;
    public TimeCardTransaction(int empId, String date, double hours) {
        this.empId = empId;
        this.date = date;
        this.hours = hours;
    }
@Override
public void execute() {

   Employee e = PayrollDatabase.getEmployee(empId);
   

   PaymentClassification pc = e.getPaymentClassification();
   if (pc instanceof HourlyClassification) {
       HourlyClassification hc = (HourlyClassification) pc;
       TimeCard tc = new TimeCard(date,hours);
       hc.addTimeCard(tc);
   }else {
    throw new NotHourlyClassificationException();
   }
}
}
